#####
cmake_minimum_required(VERSION 3.4)

set(TARGET_NAME "demo")

# project name and version
project(${TARGET_NAME} C CXX)
set(VERSION "1.0")


message("bin path is : ${PROJECT_BINARY_DIR}")
message("src path is : ${PROJECT_SOURCE_DIR}")
message("rpath is : ${RUN_LIB_PATH}")
message("PJ_ROOT_DIR is : ${PJ_ROOT_DIR}")


set(ROOT_LIB_DIR "${PJ_ROOT_DIR}/lib")
set(SRC_LIB_DIR "${PJ_ROOT_DIR}/lib")


message("ROOT_LIB_DIR is : ${ROOT_LIB_DIR}")
message("SRC_LIB_DIR is : ${SRC_LIB_DIR}")

# 编译源文件信息
set(SRC_FILES "main.cpp")

list(APPEND SRC_FILES 
     "media/connect/MediaConnect.cpp"
     "media/video/VideoRecorder.cpp"
)
aux_source_directory(./storage/dvr_svr DIR_LIB_SRCS)
aux_source_directory(./storage/ DIR_LIB_SRCS)
aux_source_directory(./storage/libJsonCplus/ DIR_LIB_SRCS)
# 最终可执行文件
add_executable(${TARGET_NAME} ${SRC_FILES} ${DIR_LIB_SRCS}) 

#set(CMAKE_SKIP_BUILD_RPATH FALSE)
#set(CMAKE_INSTALL_RPATH ${RUN_LIB_PATH})

# add_link_options(-rdynamic)

add_compile_options(-funwind-tables -ffunction-sections -rdynamic)


add_subdirectory(storage/filebox)
#添加头文件目录
target_include_directories(${TARGET_NAME} PUBLIC 
                           "${PJ_ROOT_DIR}/include"
                           "${PJ_ROOT_DIR}/include/network"
                           "${PJ_ROOT_DIR}/include/BaseUtil"
                           "${PROJECT_SOURCE_DIR}/media/video"
                           )                      

include_directories(
./storage/include 
./storage/include/common 
./storage/include/filesystem 
./storage/include/diskIO
./storage/
./storage/dvr_svr
./storage/filebox/libmov/include  
./storage/filebox/libmpeg/include
./storage/libJsonCplus
)


# 添加运行库路径
set_target_properties(${TARGET_NAME}
                      PROPERTIES
                      LINK_FLAGS "-Wl,-rpath,${RUN_LIB_PATH}/lib:/lib"
                      LINKER_LANGUAGE CXX
                      )

# libwebsockets 链接依赖库
set(LWS_LIBS "${ROOT_LIB_DIR}/libwebsockets.so.18")
#list(APPEND LWS_LIBS ${PJ_ROOT_DIR}/lib/libdl.so.2)
list(APPEND LWS_LIBS ${ROOT_LIB_DIR}/libmbedcrypto.so.5)
list(APPEND LWS_LIBS ${ROOT_LIB_DIR}/libmbedtls.so.13)
list(APPEND LWS_LIBS ${ROOT_LIB_DIR}/libmbedx509.so.1)
list(APPEND LWS_LIBS ${ROOT_LIB_DIR}/libnetwork.so)
list(APPEND LWS_LIBS ${ROOT_LIB_DIR}/libBaseUtil.so)


list(APPEND LWS_LIBS "pthread")

message("@@@@@@@@@@@___1 LWS_LIBS is : ${LWS_LIBS}")

set(THIRD_LIBS "${LWS_LIBS}")
message("@@@@@@@@@@@___3 THIRD_LIBS is : ${THIRD_LIBS}")
LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/storage/)
# 添加链接库依赖
target_link_libraries(${TARGET_NAME}  ${ROOT_LIB_DIR}/libstorage.a ${ROOT_LIB_DIR}/libcomcross.a filebox
                      ${THIRD_LIBS} 
)
set(EXECUTABLE_OUTPUT_PATH /mnt/F/ftp)

